package com.gitee.fsmxm.thinking.in.spring.bean.definition;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * bean 实例化 方式 demo
 */
public class BeanInstantiationDemo {

    public static void main(String[] args) {

        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/META-INF/bean-instantiation-context.xml");

        // 静态方法创建bean实例
        Object userByStaticMethod = applicationContext.getBean("userByStaticMethod");

        System.out.println(userByStaticMethod);

        // 实例对象创建bean实例
        Object userByInstanceMethod = applicationContext.getBean("userByInstanceMethod");

        System.out.println(userByInstanceMethod);

        // 工厂bean创建bean实例
        Object userByFactoryBean = applicationContext.getBean("userByFactoryBean");

        System.out.println(userByFactoryBean);
    }

}
